package com.central.dataManage.controller;


import com.central.common.annotation.LoginUser;
import com.central.common.model.SysUser;
import com.central.common.model.TableInfo;
import com.central.dataManage.service.ITableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author Tindy
 * @date 2021/6/24
 * @describe
 */
@Slf4j
@RestController
@Api(tags = "表管理模块api")
@RequestMapping(value = "/tableManage")
public class TableManageController {

    @Autowired
    private ITableService tableService;


    @ApiOperation(value = "获取表详情")
    @GetMapping("/findTableDetail")
    public TableInfo findTableDetail(@ApiIgnore @LoginUser SysUser user, Long tableId) {
        return tableService.findTableDetail(user,tableId);
    }

    @ApiOperation(value = "获取数据类型集合")
    @GetMapping("/findDataTypes")
    public List<String> findDataTypes(Long databaseId) {
        return tableService.findDataTypes(databaseId);
    }

    @ApiOperation(value = "获取表详情")
    @GetMapping("/pv/getTableInfo")
    public TableInfo getTableInfo(@RequestParam("datasourceId")Long datasourceId, @RequestParam("dbName") String dbName, @RequestParam("tableName") String tableName) {
        return tableService.getTableInfo(datasourceId,dbName,tableName);
    }


}
